package com.teangtang.fly.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Data;
import javax.persistence.*;
import java.util.List;

@Entity
@Data
public class Airline { // 航线
    @Id
    private String airlineNumber;

    @ManyToOne
    @JoinColumn(name = "departure_city_code")
    @JsonBackReference
    private City departureCity;

    @ManyToOne
    @JoinColumn(name = "arrival_city_code")
    @JsonBackReference
    private City arrivalCity;

    //距离
    private int distance;

    private String departureAirportName;
    private String arrivalAirportName;

    @OneToMany(mappedBy = "airline", cascade = CascadeType.ALL, orphanRemoval = true)
    @JsonManagedReference
    private List<Flight> Flights;
}